web/src/pages/[...listing].astro

722 lines · 20245 bytes

  1---
  2
  3import Layout from '@layouts/Layout.astro';
  4import ServiceList from '@components/things/ServiceList.astro';
  5import Comments from '@components/things/Comments.svelte';
  6import GitHubDetailedInfo from '@components/things/GitHubDetailedInfo.astro';
  7import PrivacyPolicyDetails from '@components/things/PrivacyPolicyDetails.astro';
  8import WebsiteDetailedInfo from '@components/things/WebsiteDetailedInfo.astro';
  9import DockerDetailedInfo from '@components/things/DockerDetailedInfo.astro';
 10import IosAppDetailedInfo from '@components/things/IosAppDetailedInfo.astro';
 11import AndroidAppDetailedInfo from '@components/things/AndroidDetailedInfo.astro';
 12import DiscordDetailedInfo from '@components/things/DiscordDetailedInfo.astro';
 13import RedditDetailedInfo from '@components/things/RedditDetailedInfo.astro';
 14import SocialShare from '@components/form/Social.astro';
 15import DataActions from '@components/things/DataActions.svelte';
 16import type { AwesomePrivacy, Section, Service } from '../types/Service';
 17import { fetchData, slugify } from '@utils/fetch-data';
 18import { fetchGitHubStats } from '@utils/fetch-repo-info';
 19import { fetchTosdrPrivacy } from '@utils/fetch-privacy-policy';
 20import { fetchWebsiteInfo } from '@utils/fetch-website-info';
 21import { fetchDockerData } from '@utils/fetch-docker-instructions';
 22import { fetchIosInfo } from '@utils/fetch-ios-info';
 23import { fetchAndroidInfo } from '@utils/fetch-android-info';
 24import { fetchDiscordInfo } from '@utils/fetch-discord-info';
 25import { fetchRedditInfo } from '@utils/fetch-reddit-info';
 26import { parseMarkdown, formatLink } from '@utils/parse-markdown';
 27import { site } from '@utils/config';
 28import FontAwesome from '@components/form/FontAwesome.svelte';
 29import Button from '@components/form/Button.astro';
 30import SaveListing from '@components/things/SaveListing.svelte';
 31
 32interface Props extends Service {
 33  slug: string;
 34  parentSection: Section;
 35  categoryName: string;
 36}
 37
 38const {
 39  name,
 40  description,
 41  url,
 42  github,
 43  tosdrId,
 44  discordInvite,
 45  subreddit,
 46  iosApp,
 47  androidApp,
 48  icon,
 49  followWith,
 50  links,
 51  securityAudited,
 52  openSource,
 53  acceptsCrypto,
 54  parentSection,
 55  categoryName,
 56} = Astro.props;
 57
 58
 59/**
 60 * Make a list of keywords, for the <meta keywords> tag
 61 */
 62const makeKeyWordTag = () => {
 63  const keywords: string[] = [];
 64  keywords.push(`open source ${parentSection.name}`);
 65  keywords.push(`${parentSection.name} comparison`);
 66  (parentSection.alternativeTo || []).forEach((alt: string) => {
 67    keywords.push(`${alt} alternative`);
 68  });
 69  (parentSection.services || []).forEach((serv: Service) => {
 70    keywords.push(`${serv.name} vs`);
 71  });
 72  keywords.push('private');
 73  keywords.push('ad free');
 74  keywords.push('encrypted');
 75  keywords.push('open source software');
 76  keywords.push('privacy respecting apps');
 77  keywords.push('free tools');
 78  return keywords.join(', ');
 79};
 80
 81/**
 82 * Make a page title
 83 */
 84const makePageTitle = () => {
 85  return `${name} | ${parentSection.name} | ${categoryName} | Awesome Privacy`;
 86};
 87
 88const makeBreadcrumbs = () => {
 89  return [
 90    { name: 'Home', item: '/' },
 91    { name: categoryName, item: slugify(categoryName) },
 92    { name: parentSection.name, item: `${slugify(categoryName)}/${slugify(parentSection.name)}` },
 93    { name: name, item: `${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)}` },
 94  ];
 95};
 96
 97/**
 98 * Make a string page intro, for the description tag
 99 */
100const makeDescriptionTag = () => {
101  let description = `Analysis of ${name}, and other privacy-respecting ${parentSection.name} `;
102  if (parentSection.services) {
103    const serviceList = parentSection.services.map((serv: Service) => serv.name);
104    description += `Compare ${serviceList.join(' vs ')} more apps. `
105  }
106  if (parentSection.alternativeTo && parentSection.alternativeTo.length > 0) {
107    description += `The best secure encrypted alternatives to ${parentSection.alternativeTo.join(', ')} in 2024. `;
108  }
109  description += 'All this, and many more free and awesome tools and software.'
110  return description;
111};
112
113// Return a list of Services, except for the currtent one
114const filterServices = () => {
115  return parentSection.services.filter((service: Service) => service.name !== name);
116};
117
118export async function getStaticPaths() {
119  const pages = await fetchData().then((data) => {
120    const results: Array<Props> = [];
121    if (!data || !data.categories) return results;
122    (data as AwesomePrivacy).categories.forEach((category) => {
123      category.sections.forEach((section) => {
124        const services = (section.services || []).map((service) => {
125          return {
126            slug: `${slugify(category.name)}/${slugify(section.name)}/${slugify(service.name)}`,
127            parentSection: section,
128            categoryName: category.name,
129            ...service,
130          };
131        });
132        results.push(...services);
133      });
134      
135    });
136    return results;
137  });
138
139  return pages.map((props: Props) => {
140    return {params: { listing: props.slug }, props };
141  });
142}
143
144const makePaginationLinks = () => {
145  const allServices = parentSection.services || [];
146  const index = allServices.findIndex(item => item.name === name);
147  const previousItem = index >  0 ? allServices[index -  1].name : null;
148  const nextItem = index < allServices.length -  1 ? allServices[index +  1].name : null;
149  return { previous: previousItem, next: nextItem };
150};
151
152const { previous, next } = makePaginationLinks();
153
154const ignoredSites = ['github.gom', 'wikipedia.'];
155
156// Fetch detailed data about the services GitHub repo, privacy policy and website
157const githubData = github ? await fetchGitHubStats(github) : null;
158const privacyData = tosdrId ? await fetchTosdrPrivacy(tosdrId) : null;
159const iosData = iosApp ? await fetchIosInfo(iosApp) : null;
160const androidData = androidApp ? await fetchAndroidInfo(androidApp) : null;
161const discordData = discordInvite ? await fetchDiscordInfo(discordInvite) : null;
162const redditData = subreddit ? await fetchRedditInfo(subreddit) : null;
163const dockerData = await fetchDockerData(name);
164const websiteData = (url && !ignoredSites.some(ignoredSite => url.includes(ignoredSite))) ? await fetchWebsiteInfo(url) : null;
165
166const findPrivacyPolicyLink = () => {
167  if (!privacyData) return null;
168  const docs = privacyData.parameters.documents;
169  if (docs) {
170    const privacyPolicy = (docs || []).find((doc) => doc.name.toLowerCase().includes('privacy policy'));
171    if (privacyPolicy) return privacyPolicy.url;
172  }
173  return `https://tosdr.org/en/service/${tosdrId}`;
174};
175
176const privacyPolicyLink = findPrivacyPolicyLink();
177
178const getApiEndpoint = () => {
179  return `https://api.awesome-privacy.xyz/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)}`;
180}
181
182---
183
184<Layout
185  title={makePageTitle()}
186  keywords={makeKeyWordTag()}
187  description={makeDescriptionTag()}
188  breadcrumbs={makeBreadcrumbs()}
189>
190  <main>
191    <section>
192      <div class="service-head">
193        <h2>{name}</h2>
194        <span class="url-wrap">
195          <a class="service-url" href={url}>{formatLink(url)}</a>
196          <span class="follow-with">{followWith}</span>
197        </span>
198      </div>
199      <div class="breadcrumbs">
200        <span>
201          <a href="/">Awesome Privacy</a>
202          ➔ <a href={`/${slugify(categoryName)}`}>{categoryName}</a>
203          ➔ <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}`}>{parentSection.name}</a>
204          ➔ <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)}`}>{name}</a>
205        </span>
206      </div>
207      <div class="save-listing">
208        <SaveListing client:visible
209          categoryName={categoryName}
210          sectionName={parentSection.name}
211          serviceName={name}
212          showLabel={true}
213        />
214      </div>
215      <div class="intro">
216        <img 
217          width="60"
218          height="60"
219          loading="lazy"
220          decoding="async"
221          class="service-icon"
222          alt={`${name} Icon`}
223          data-service-url={formatLink(url)}
224          src={icon || `https://icon.horse/icon/${formatLink(url)}`}
225        />
226        <div>
227        <p class="description" set:html={parseMarkdown(description)}></p>
228        <ul>
229          { url && (
230          <li>
231            <b>Homepage:</b>
232            <a href={url}>{formatLink(url)}</a>
233          </li>
234          )}
235          { github && (
236          <li>
237            <b>GitHub:</b>
238            <a href={`https://github.com/${github}`}>github.com/{github}</a>
239          </li>
240          )}
241          { tosdrId && (
242          <li>
243            <b>Privacy:</b>
244            <a href={privacyPolicyLink}>{formatLink(privacyPolicyLink || '')}</a>
245          </li>
246          )}
247          { iosApp && (
248          <li>
249            <b>iOS App:</b>
250            <a href={iosApp}>{formatLink(iosApp)}</a>
251          </li>
252          )}
253          { androidApp && (
254          <li>
255            <b>Android App:</b>
256            <a href={`https://play.google.com/store/apps/details?id=${androidApp}`}>{`https://play.google.com/store/apps/details?id=${androidApp}`}</a>
257          </li>
258          )}
259          { discordInvite && (
260          <li>
261            <b>Discord Invite:</b>
262            <a href={`https://discord.com/invite/${discordInvite}`}>{discordInvite}</a>
263          </li>
264          )}
265          { subreddit && (
266          <li>
267            <b>Subreddit:</b>
268            <a href={`https://reddit.com/r/${subreddit}`}>r/{subreddit}</a>
269          </li>
270          )}
271          { url && (
272          <li>
273            <b>Web info:</b>
274            <a href={`https://web-check.xyz/results/${formatLink(url)}`}>{`web-check.xyz/results/${formatLink(url).split('/')[0]}`}</a>
275          </li>
276          )}
277          { links && links.length > 0 && (
278            links.map((link) => (
279              <li>
280                <b>{link.title}</b>
281                <a href={link.url}>{link.url}</a>
282              </li>
283            ))
284          )}
285        </ul>
286        </div>
287      </div>
288      <div class="highlights">
289        { securityAudited && (
290          <span class="meta-item great" title={`${name} has been security audited by an accredited auditor, with results published publicly`}>
291            <FontAwesome iconName="securityAudited" /> Security Audited
292          </span>
293        )}
294        { acceptsCrypto && (
295          <span class="meta-item great" title={`${name} accepts anonymous payment methods`}>
296            <FontAwesome iconName="cryptoAccepted" /> Crypto Payments Accepted
297          </span>
298        )}
299        { securityAudited === false && (
300          <span class="meta-item warning" title={`${name} has not been audited`}>
301            <FontAwesome iconName="notSecurityAudited" /> No Security Audit
302          </span>
303        )}
304        { (openSource === false) && (
305          <span class="warning">
306            <FontAwesome iconName="closedSource" />
307            Not Open Source
308          </span>
309        )}
310        { openSource || (github && openSource !== false) ? (
311          <span class="meta-item great" title={`${name} is open source`}>
312            <FontAwesome iconName="openSource" /> Open Source
313          </span>
314        ) : null }
315      </div>
316    </section>
317    { privacyData && privacyData.parameters.points.length > 0 && (
318      <section>
319        <h3>{name} Privacy Policy</h3>
320        <PrivacyPolicyDetails privacyData={privacyData} />
321      </section>
322    )}
323    { github && githubData && (
324      <section class="github-wrap">
325        <h3>{name} Source Code</h3>
326        <GitHubDetailedInfo gitHubData={githubData} repo={github} />
327      </section>
328    )}
329    { websiteData && (
330      <section>
331        <h3>{name} Website</h3>
332        <WebsiteDetailedInfo url={url} websiteInfo={websiteData} />
333      </section>
334    )}
335    { (androidData && !androidData.error) && (
336      <section>
337        <h3>{name} Android App</h3>
338        <AndroidAppDetailedInfo androidData={androidData} />
339      </section>
340    )}
341    { iosData && (
342      <section>
343        <h3>{name} iOS App</h3>
344        <IosAppDetailedInfo url={url} iosData={iosData} />
345      </section>
346    )}
347    { dockerData && dockerData.found && (
348    <section>
349      <h3>{name} Docker</h3>
350      <DockerDetailedInfo docker={dockerData} />
351    </section>
352    )}
353    { (discordData || redditData) && (
354    <section>
355      <h3>{name} Socials</h3>
356      <div class="social-wrap">
357      { discordData && <DiscordDetailedInfo discordData={discordData} /> }
358      { redditData && <RedditDetailedInfo redditData={redditData} /> }
359      </div>
360    </section>
361    )}
362
363    <section>
364      <h3>{name} Reviews</h3>
365      <Comments client:visible />
366    </section>
367
368    <section>
369      <h3>More {parentSection.name}</h3>
370      <ServiceList
371        services={filterServices()}
372        subHeading={true}
373        noGitHubMetrics={true}
374        buttonLink={`/${slugify(categoryName)}/${slugify(parentSection.name)}`}
375        categoryName={categoryName}
376        sectionName={parentSection.name}
377      />
378    </section>
379    <section>
380      <h3>About the Data: {name}</h3>
381      <DataActions client:load categoryName={categoryName} sectionName={parentSection.name} serviceName={name} />
382      <h4>API</h4>
383      <p>
384        You can access {name}'s data programmatically via our API.
385        Simply make a <code>GET</code> request to:
386      </p>
387      <pre><a href={getApiEndpoint()}><code>{getApiEndpoint()}</code></a></pre>
388      <p>
389        The REST API is free, no-auth and CORS-enabled.
390        To learn more, view the  <a href="/api">Swagger Docs</a> or read the <a href="/about#api">API Usage Guide</a>.
391      </p>
392
393      <h4>About the Data</h4>
394      <p>
395        Beyond the user-submitted YAML you see above, we also augment each listing with
396        additional data dynamically fetched from several sources.
397        To learn more about where the rest of data included in this page comes from,
398        and how it is computed,
399        see the <a href="/about#our-data">About the Data</a> section of our About page.
400      </p>
401    </section>
402
403    <section>
404      <h3>Share {name}</h3>
405      <p>
406        Help your friends compare {parentSection.name}, and pick privacy-respecting software and services.<br />
407        Share {name} and Awesome Privacy with your network!
408        <div>
409          <SocialShare
410            url={`${site}/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)} `}
411            title={`Checkout ${name}! \n`}
412            description={
413            `Compare #${name} and other privacy-respecting ${parentSection.name} at `
414            + `Awesome-Privacy.xyz, the free and open source list of private software alternatives. `
415            + `#privacy #opensource #awesomeprivacy by @Lissy_Sykes`}
416          />
417        </div>
418      </p>
419    </section>
420
421    <div class="pagination-navigation">
422      { previous ? (
423        <Button url={`/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(previous)}`}>
424          <span>← Previous</span>
425          <p>{previous}</p>
426        </Button>
427      ) : <p class="nothing"></p>}
428      <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}`} class="go-to-category">
429        View {parentSection.name} ({(parentSection.services || []).length})
430      </a>
431      { next && (
432        <Button url={`/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(next)}`}>
433          <span>Next →</span>
434          <p>{next}</p>
435        </Button>
436      )}
437    </div>
438  </main>
439</Layout>
440
441<style lang="scss">
442
443main {
444  margin: 2rem auto;
445  padding: 1rem;
446  width: 1200px;
447  max-width: calc(100% - 5rem);
448  position: relative;
449  @media(max-width: 768px) {
450    max-width: 95%;
451    padding: 0.5rem;
452    margin: 0 auto;
453  }
454}	
455
456section {
457  margin: 1rem 0 4rem 0;
458  padding: 1rem;
459  min-height: 8rem;
460  position: relative;
461  border: 2px solid var(--box-outline);
462  box-shadow: 6px 6px 0 var(--box-outline);
463  background: var(--accent-fg);
464
465}
466
467p {
468  margin: 0.25rem 0 0.5rem 0;
469}
470
471h3 {
472    font-size: 2rem;
473    margin: -2rem 0 1rem -2rem;
474    box-shadow: 6px 6px 0 var(--box-outline);
475    background: var(--accent);
476    color: var(--accent-fg);
477    width: fit-content;
478    padding: 0.25rem 0.5rem;
479    @media(max-width: 768px) {
480      margin: -2rem auto 2rem auto;
481    }
482  }
483
484.service-head {
485  h2 {
486    font-size: 3rem;
487    margin: 0;
488    @media(max-width: 768px) {
489      text-align: center;
490    }
491  }
492  .url-wrap {
493    display: flex;
494    align-items: center;
495    gap: 0.5rem;
496    a {
497      font-size: 1.2rem;
498    }
499    .follow-with {
500      font-style: italic;
501      opacity: 0.6;
502    }
503    @media(max-width: 768px) {
504      flex-direction: column;
505    }
506  }
507  
508}
509
510.breadcrumbs {
511  opacity: 0.5;
512  font-size: 0.8rem;
513  position: absolute;
514  right: 1rem;
515  top: 1rem;
516  a {
517    color: var(--foreground);
518    transition: all 0.15s ease-in-out;
519    
520    &:hover {
521      color: var(--accent);
522    }
523  }
524  @media(max-width: 768px) {
525    display: none;
526  }
527}
528
529.save-listing {
530  position: absolute;
531  top: 3rem;
532  right: 1rem;
533}
534
535h4 {
536  font-size: 1.4rem;
537  margin-bottom: 0;
538}
539
540.intro {
541  font-size: 1.2rem;
542  font-style: italic;
543  opacity: 0.9; 
544  display: flex;
545  gap: 0.5rem;
546  @media(max-width: 768px) {
547    flex-direction: column; 
548  }
549  .service-icon {
550    border-radius: var(--curve-md);
551    margin-top: 1rem;
552    @media(max-width: 768px) {
553      margin: 1rem auto 0 auto;
554    }
555  }
556  ul {
557    padding-left: 1rem;
558    list-style: circle;
559    font-style: normal;
560    font-size: 1rem;
561    margin-top: 0;
562    b {
563      font-size: 1rem;
564      font-weight: 400;
565      min-width: 100px;
566      display: inline-block;
567      @media(max-width: 768px) {
568        width: auto;
569        display: block;
570      }
571    }
572  }
573}
574
575.pagination-navigation {
576  display: flex;
577  justify-content: space-between;
578  align-items: center;
579  padding: 1rem 0;
580  :global(.button) {
581    min-width: 120px;
582    width: fit-content;
583    padding: 0.25rem 1rem;
584    text-align: right;
585    &:first-child { text-align: left; }
586    p {
587      margin: 0;
588      font-weight: normal;
589      font-size: 1rem;
590    }
591    span {
592      font-size: 0.8rem;
593    }
594    
595  }
596  .nothing {
597    width: 120px;
598  }
599  .go-to-category {
600    color: var(--foreground);
601    font-size: 0.8rem;
602    opacity: 0.5;
603    @media (max-width: 768px) {
604      display: none;
605    }
606  }
607}
608
609
610
611.further-info, .notable-mentions, .word-of-warning {
612  h3 {
613    font-size: 1.4rem;
614    margin: 1rem 0;
615  }
616  :global(p) {
617    font-size: 0.9rem;
618    opacity: 0.7; 
619    :global(strong) {
620      font-weight: 500;
621    }
622    :global(a) {
623      color: var(--foreground);
624      transition: all 0.15s ease-in-out;
625      &:hover {
626        color: var(--accent);
627      }
628    }
629  }
630  :global(strong) {
631    font-weight: 500;
632  }
633  :global(h4) {
634    font-size: 1.2rem;
635    margin: 0.5rem 0 0 0;
636  }
637  :global(ul) {
638    list-style: circle;
639    padding-left: 1rem;
640    font-size: 0.9rem;
641    opacity: 0.7;
642    li {
643      margin-bottom: 0.25rem;
644      :global(p) {
645        display: inline;
646      }
647    }
648  }
649}
650
651pre {
652  a {
653    text-decoration: none;
654    color: var(--foreground);
655    code {
656      background: #acabb782;
657      padding: 0.2rem 0.4rem;
658      border-radius: var(--curve-sm);
659      font-family: Courier New;
660      font-size: 0.9rem;
661      @media(max-width: 768px) {
662        white-space: break-spaces;
663      }
664    }
665  }
666}
667
668.social-wrap {
669  display: flex;
670  gap: 1rem;
671  flex-wrap: wrap;
672  justify-content: space-between;
673}
674
675.highlights {
676  display: flex;
677  gap: 1rem;
678  flex-wrap: wrap;
679  align-items: center;
680  justify-content: end;
681
682  .meta-item, .warning {
683    display: flex;
684    align-items: center;
685    // justify-content: center;
686    gap: 0.25rem;
687    opacity: 0.6;
688    font-size: 0.9rem;
689    padding: 0.5rem 0;
690    :global(svg) {
691      color: var(--foreground);
692      width: 1.2rem;
693      height: 1.2rem;
694    }
695    a {
696      text-decoration: none;
697      color: var(--foreground);
698      display: flex;
699      gap: 0.25rem;
700      &:hover {
701        color: var(--accent-3);
702        :global(svg) {
703          color: var(--accent-3);
704        }
705      }
706    }
707  }
708  .warning {
709    color: var(--danger);
710    :global(svg) {
711      color: var(--danger);
712    }
713  }
714  .great {
715    color: #007930; // var(--success);
716    :global(svg) {
717      color: #007930; // var(--success);
718    }
719  }
720}
721
722</style>